package com.dstats;
 
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.widget.ProgressBar;
 
public class SimpleWebView extends Activity {
 
	private WebView webView;
	private ProgressBar loadingProgressBar;
	private AdView mAdView;


    @Override
    protected void onPause() {
        mAdView.pause();
        super.onPause();
    }

    @Override
    protected void onResume() {
        super.onResume();
        mAdView.resume();
    }

    @Override
    protected void onDestroy() {
        mAdView.destroy();
        super.onDestroy();
    }
	
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.simple_web_view);
		 mAdView = (AdView) findViewById(R.id.adViewWeb);
	     mAdView.loadAd(new AdRequest.Builder().build());
		
		loadingProgressBar=(ProgressBar)findViewById(R.id.progressBarWebView); 
		loadingProgressBar.setMax(100);
		webView = (WebView) findViewById(R.id.webView1);
		webView.getSettings().setJavaScriptEnabled(true);
		webView.getSettings().setSupportZoom(true); 
		webView.getSettings().setBuiltInZoomControls(true);
		webView.getSettings().setUseWideViewPort(true);
		webView.getSettings().setLoadWithOverviewMode(true);
		webView.setInitialScale(1);
		webView.getSettings().setUserAgentString("Chrome");
		webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
		webView.setScrollbarFadingEnabled(false);
		webView.loadUrl(getIntent().getStringExtra("url"));
		webView.setWebChromeClient(new WebChromeClient() {

			   // this will be called on page loading progress

			   @Override

			   public void onProgressChanged(WebView view, int newProgress) {

			   super.onProgressChanged(view, newProgress);

			   loadingProgressBar.setProgress(newProgress);
			   //loadingTitle.setProgress(newProgress);
			   // hide the progress bar if the loading is complete

			   if (newProgress == 100) {
				   loadingProgressBar.setVisibility(View.GONE);
				   } else{
				   loadingProgressBar.setVisibility(View.VISIBLE); 
				   }
			   }
			   });
 
	}
 
}